﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GraphGeneration
{
    public class Edge
    {

        public Vertex from { get; private set; }
        public Vertex to { get; private set; }
        public double Weight { get; set; }

        public Edge(): this(null,null, 1) {}        
        public Edge(Vertex f, Vertex t) : this(f, t, 1) { }
        public Edge(Vertex f, Vertex t, double w)
        {
            //What if f or t are null?
            if(t == null || f == null)
            throw new NullReferenceException();

            setVertex(f, t);
            Weight = w;
        }


        public bool setVertex(Vertex f, Vertex t)
        {
            if (f == null || t == null)
                return false;

            from = f;
            to = t;

            from.addEdge(this);

            return true;
        }

        public bool removeEdge()
        {
            if (from.RemoveEdge(this))
                return true;

            return false;
        }

        public Vertex[] getVertex()
        {
            Vertex[] s = new Vertex[3];
            s[0] = from;
            s[1] = to;
            return s;
        }


    }
}
